package com.tzg157.fitness.service;

import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.tzg157.fitness.service.realtime.ods.ODSMemberInfoServiceImpl;
import lombok.RequiredArgsConstructor;
import org.apache.spark.sql.SparkSession;
import org.springframework.stereotype.Service;

import java.io.Serializable;

@Service
@RequiredArgsConstructor
public class ResolveKafkaRecordService implements Serializable {

    private final ODSMemberInfoServiceImpl odsMemberInfoServiceImpl;

    public void resolve(String record, SparkSession spark) {
        JSONObject jsonObject = JSONUtil.parseObj(record);
        String type = (String) jsonObject.get("type");
        if("register".equals(type)){
            odsMemberInfoServiceImpl.save(jsonObject,spark);
        }
        System.out.println(record);
    }
}
